import axios from 'axios'
import request from "../utils/request";

export const articleApi = {
    // 获取文章列表
    getArticles(page = 0, pageSize = 10, category = 'recommend') {
        return request.post('/articles', {
            page: page,
            size: pageSize,
            category: category,
        });
    },

    // 搜索文章
    searchArticles(keyword, page = 0, size = 10) {
        return request.get(`/articles/search`, {
            params: { keyword, page, size }
        })
    },

    // 获取文章详情
    getArticle(id) {
        return request.get(`/articles/${id}`)
    },

    // 获取最新文章
    getLatestArticles(limit = 10) {
        return request.get(`/articles/latest`, { params: { limit } })
    },

    // 获取热门文章
    getPopularArticles(limit = 10) {
        return request.get(`/articles/popular`, { params: { limit } })
    },

    // 获取浏览量
    getArticleViewCount(id) {
        return request.get(`/articles/${id}/viewCount`)
    }
}
